using UnityEngine;

public class TitanTransformPhoton : PhotonTransformView
{
	public TitanBehavior titan;

	public float topPartRotSpeed = 4f;

	public float bottomPartRotSpeed = 2f;

	public float topPartRot;

	public float bottomPartRot;

	private Camera mainCamera;

	public override void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		base.OnPhotonSerializeView(stream, info);
		if (stream.isWriting)
		{
			if (mainCamera == null)
			{
				mainCamera = Camera.main;
			}
			stream.SendNext((int)titan.topTitanPart.eulerAngles.y);
			stream.SendNext((int)titan.bottomTitanPart.eulerAngles.y);
			stream.SendNext(titan.mainWeaponsShooting);
			stream.SendNext(titan.additionalWeaponsShooting);
			stream.SendNext(titan.health);
			stream.SendNext(titan.titanController.usingJetpack);
		}
		else
		{
			topPartRot = (int)stream.ReceiveNext();
			bottomPartRot = (int)stream.ReceiveNext();
			titan.mainWeaponsShooting = (bool)stream.ReceiveNext();
			titan.additionalWeaponsShooting = (bool)stream.ReceiveNext();
			titan.health = (int)stream.ReceiveNext();
			titan.titanController.usingJetpack = (bool)stream.ReceiveNext();
		}
	}

	private void LateUpdate()
	{
		if (!(titan == null) && !titan.isMine && !titan.isDead)
		{
			titan.topTitanPart.eulerAngles = Vector3.Lerp(titan.topTitanPart.eulerAngles, new Vector3(0f, topPartRot, 0f), Time.deltaTime * topPartRotSpeed);
			titan.bottomTitanPart.eulerAngles = Vector3.Lerp(titan.bottomTitanPart.eulerAngles, new Vector3(0f, bottomPartRot, 0f), Time.deltaTime * bottomPartRotSpeed);
		}
	}
}
